package com.xtayfjpk.commons.daemon.test;

import org.apache.commons.daemon.Daemon;
import org.apache.commons.daemon.DaemonContext;
import org.apache.commons.daemon.DaemonInitException;

public class HelloService implements Daemon {
	private boolean stop = false;

	@Override
	public void init(DaemonContext context) throws DaemonInitException,	Exception {
	}

	@Override
	public void start() throws Exception {
		System.out.println("start");
		while (!stop) {
			try {

				Thread.sleep(1000);

			} catch (InterruptedException e) {

			}
			System.out.println("running");
		}		
	}

	@Override
	public void stop() throws Exception {
		stop = true;		
	}

	@Override
	public void destroy() {
		System.exit(0);		
	}

}
